<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> 
    <title> - 天地维杰网</title>
    <meta name="keywords" content="系统架构,shutdown,不与天斗,Domino,博客,程序员,架构师,笔记,技术,分享,java,Redis">
    
    <meta property="og:title" content="">
    <meta property="og:site_name" content="天地维杰网">
    <meta property="og:image" content="/img/author.jpg"> 
    <meta name="title" content=" - 天地维杰网" />
    <meta name="description" content="天地维杰网 | 博客 | 软件 | 架构 | Java "> 
    <link rel="shortcut icon" href="http://www.shutdown.cn/img/favicon.ico" />
    <link rel="apple-touch-icon" href="http://www.shutdown.cn/img/apple-touch-icon.png" />
    <link rel="apple-touch-icon-precomposed" href="http://www.shutdown.cn/img/apple-touch-icon.png" />
    <link href="http://www.shutdown.cn/js/vendor/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
    <link href="http://www.shutdown.cn/js/vendor/fancybox/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
    <link href="http://www.shutdown.cn/css/main.css" rel="stylesheet" type="text/css" />
    <link href="http://www.shutdown.cn/css/syntax.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
     fancybox: true, 
    motion: true
  };
</script>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
<div class="container one-collumn sidebar-position-left page-home  ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"> <div class="site-meta  custom-logo ">

  <div class="custom-logo-site-title">
    <a href="http://www.shutdown.cn"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">天地维杰网</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">人如秋鸿来有信，事若春梦了无痕</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
    <ul id="menu" class="menu">
      
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/redis/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-battery-full"></i> <br />Redis
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/java/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-coffee"></i> <br />java
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/linux/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-linux"></i> <br />linux
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/daily/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-bug"></i> <br />日常问题
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/spring/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-child"></i> <br />Spring和Springboot
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/spring/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-fire"></i> <br />Mac相关
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/middleware/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-gavel"></i> <br />中间件
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/jiagou/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-rocket"></i> <br />架构
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/python/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-ship"></i> <br />python
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/front/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-bolt"></i> <br />前端
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/jvm/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-balance-scale"></i> <br />JVM
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/post/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/about/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />关于
          </a>
        </li>
      
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger"> <i class="menu-item-icon fa fa-search fa-fw"></i> <br /> 搜索</a>
      </li>
    </ul>
    <div class="site-search">
      <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>

    </div>
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
<section id="posts" class="posts-expand">
  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <header class="post-header">
      <h1 class="post-title" itemprop="name headline">
        <a class="post-title-link" href="http://www.shutdown.cn/post/k8s/" itemprop="url">
        
        </a>
      </h1>
      <div class="post-meta">
      <span class="post-time">
<span class="post-meta-item-icon">
    <i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">时间：</span>
<time itemprop="dateCreated" datetime="2016-03-22T13:04:35+08:00" content="0001-01-01">
    0001-01-01
</time>
</span> 
      
      
       <span>
&nbsp; | &nbsp;
<span class="post-meta-item-icon">
    <i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读：</span>
<span class="leancloud-visitors-count">976 字 ~5分钟</span>
</span>
      </div>
    </header>
    <div class="post-body" itemprop="articleBody">
    

    

<p>10.4.7.21 10.4.7.22 10.4.7.200 上</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#8f5902;font-style:italic"># 关闭防火强</span>
systemctl stop firewalld
<span style="color:#8f5902;font-style:italic"># 安装 epel</span>
yum install epel-release
<span style="color:#8f5902;font-style:italic"># 安装常用工具</span>
yum install wget net-tools telnet tree nmap sysstat lrzsz dos2unix bind-utils nc -y</code></pre></div>
<p>10.4.7.11 上</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#8f5902;font-style:italic"># 关闭防火强</span>
systemctl stop firewalld
<span style="color:#8f5902;font-style:italic"># 安装 epel</span>
yum install epel-release
<span style="color:#8f5902;font-style:italic"># 安装常用工具</span>
yum install wget net-tools telnet tree nmap sysstat lrzsz dos2unix bind-utils nc -y

yum install <span style="color:#204a87">bind</span> -y</code></pre></div>
<p>​<br />
    vi /etc/named.conf</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">    # 监听地址 ，原来是127.0.0.1
    listen-on port 53 { 10.4.7.11; };

    # 哪些客户端可以查询dns解析
    allow-query     { any; };
    # 不加这句可会访问不到外网
    allow-query-cache       { any; };
    forwarders      { 10.4.7.1; };

    # 递归
    recursion yes;

    dnssec-enable no;
    dnssec-validation no;

vi /etc/named.rfc1912.zones

    #增加
    zone &#34;host.com&#34; IN {
        type  master;
        file  &#34;host.com.zone&#34;;
        allow-update { 10.4.7.11; };
    };

    zone &#34;od.com&#34; IN {
        type master;
        file &#34;od.com.zone&#34;;
        allow-update { 10.4.7.11; };
    };

vi /var/named/host.com.zone

    $ORIGIN host.com
    $TTL 600    ; 10 minutes
    @   IN SOA  dns.host.com dnsadmin.host.com. (
                    2021041601 ; serial
                    100800     ; refresh (3 hours)
                    900        ; retry (15 minutes)
                    604800     ; expire (1 week)
                    86400      ; minimum (1 day)
                    )
                NS    dns.host.com.

    $TTL 60 ; 1 minute
    dns        A    10.4.7.11
    HDSS7-11       A    10.4.7.11
    HDSS7-12           A    10.4.7.12
    HDSS7-21           A    10.4.7.21
    HDSS7-22           A    10.4.7.22
    HDSS7-200          A    10.4.7.200</code></pre></div>
<p>​<br />
    配置完后使用named-checkconf 命令检查配置是否正确，无报错即为ok
        [root@hdss7-11 named]# named-checkconf
    启动named
        [root@hdss7-11 named]# systemctl start named
    查看53端口
        [root@hdss7-11 named]# netstat -luntp|grep 53
        tcp        0      0 10.4.7.11:53            0.0.0.0:*               LISTEN      1812/named
        tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      1812/named
        tcp6       0      0 ::1:953                 :::*                    LISTEN      1812/named
        udp        0      0 10.4.7.11:53            0.0.0.0:*                           1812/named
    检查是否解析
        [root@hdss7-11 named]# dig -t A hdss7-21.host.com @10.4.7.11 +short
        10.4.7.21</p>

<p>​<br />
    将dns解析改为 本机的dns
        [root@hdss7-11 named]#vi /etc/sysconfig/network-scripts/ifcfg-ens33</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">    GATEWAY=10.4.7.1
    IPADDR=10.4.7.11
    NETMASK=255.255.255.0
    DNS1=10.4.7.11

重启网络
    systemctl restart network

再访问解析ping baidu.com和 ping hdss7-12.host.com，都可以ping的通，其他的服务器设置dns1为 10.4.7.11以后，也可以对 .host.com的域名进行正常解析，外网也可以ping的通

PS:必须关闭dns机器防火墙，否则无法正常访问</code></pre></div>
<p>​</p>

<h3 id="签发证书环境">签发证书环境</h3>

<p>k8s基本所有组件通信都依赖ssl通信，所以需要有证书，方式有两种 ，一种是openssl，一种是cfssl</p>

<p>cfssl的官网是<code>https://pkg.cfssl.org/</code></p>

<p>hdss7-200上 cfssl、cfssl-json、cfssl-certinfo 下载</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 -O /usr/bin/cfssl
wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 -O /usr/bin/cfssl-certinfo
wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 -O /usr/bin/cfssl-json</code></pre></div>
<p>修改权限</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">chmod +x cfssl*</code></pre></div>
<p>​<br />
进入/opt目录进行签证书操作，创建文件ca-csr.json</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">touch /opt/certs/ca-csr.json

{
  &#34;CN&#34;: &#34;kubernetes&#34;,
  &#34;hosts&#34;: [
  ],
  &#34;key&#34;: {
    &#34;algo&#34;: &#34;rsa&#34;,
    &#34;size&#34;: 2048
  },
  &#34;names&#34;: [{
    &#34;C&#34;: &#34;CN&#34;,
    &#34;ST&#34;: &#34;beijing&#34;,
    &#34;L&#34;: &#34;beijing&#34;,
    &#34;O&#34;: &#34;jxy&#34;,
    &#34;OU&#34;: &#34;jg&#34;
  }],
  &#34;ca&#34;: {
    &#34;expiry&#34;: &#34;175200h&#34;
  }
}

{
  //COMMON NAME 浏览器使用该字段验证网站是否合法，一般写的是域名，非常重要
  &#34;CN&#34;: &#34;kubernetes&#34;,
  &#34;hosts&#34;: [
  ],
  &#34;key&#34;: {
    //算法
    &#34;algo&#34;: &#34;rsa&#34;,
    &#34;size&#34;: 2048
  },
  &#34;names&#34;: [{
    //COUNTRY 国家
    &#34;C&#34;: &#34;CN&#34;,
    //STATE 省
    &#34;ST&#34;: &#34;beijing&#34;,
    //Locality 城市
    &#34;L&#34;: &#34;beijing&#34;,
    // ORGANIZATION 组织名/公司名
    &#34;O&#34;: &#34;jxy&#34;,
    // ORGANIZATION UNIT 组织单位/公司部门
    &#34;OU&#34;: &#34;jg&#34;
  }],
  &#34;ca&#34;: {
    &#34;expiry&#34;: &#34;175200h&#34;
  }
}</code></pre></div>
<p>生成cas-csr.json文件生成证书</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">[root@hssd7-200 certs]# cfssl gencert -initca ca-csr.json | cfssl-json -bare ca
2021/04/16 17:44:23 [INFO] generating a new CA key and certificate from CSR
2021/04/16 17:44:23 [INFO] generate received request
2021/04/16 17:44:23 [INFO] received CSR
2021/04/16 17:44:23 [INFO] generating key: rsa-2048
2021/04/16 17:44:24 [INFO] encoded CSR
2021/04/16 17:44:24 [INFO] signed certificate with serial number 712747934164961061141797353652272536418344104280</code></pre></div>
<p>可以看到生成的文件</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">[root@hssd7-200 certs]# ls -l
总用量 16
-rw-r--r--. 1 root root  985 4月  16 17:44 ca.csr
-rw-r--r--. 1 root root  234 4月  16 17:37 ca-csr.json
#根证书的私钥
-rw-------. 1 root root 1679 4月  16 17:44 ca-key.pem
#根证书
-rw-r--r--. 1 root root 1330 4月  16 17:44 ca.pem</code></pre></div>
<h3 id="准备docker环境">准备docker环境</h3>

<p>10.4.7.21 、 10.4.7.22 、10.4.7.200 三台分别进行以下操作</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># 快速安装docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun</code></pre></div>
<p>docker安装过程中会卡一阵，要等会，直到结束，不要中途中断如下图</p>

<div  align="center"><img src="https://wejack639.oss-cn-beijing.aliyuncs.com/blogimages/img/1618570512715-20210416185510.png" width = 800 /> </div>    

<p>安装好docker以后，要配置docker的配置文件</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">vi /etc/docker/daemon.json
{
  &#34;graph&#34;: &#34;/data/docker&#34;,
  &#34;storage-driver&#34;: &#34;overlay2&#34;,
  &#34;insecure-registries&#34;: [&#34;registry.access.redhat.com&#34;,&#34;quay.io&#34;,&#34;harbor.od.com&#34;],
  &#34;registry-mirrors&#34;: [&#34;https://q2gr04ke.mirror.aliyuncs.com&#34;],
  &#34;bip&#34;: &#34;172.7.21.1/24&#34;,
  &#34;exec-opts&#34;: [&#34;native.cgroupdriver=systemd&#34;],
  &#34;live-restore&#34;: true
}
这里的 bip部分要与服务器的ip一致，如在 10.4.7.21服务器配置，bip就要设置为  172.7.21.1/24

graph属性里面配置的目录要进行创建

mkdir -p /data/docker </code></pre></div>
<p>​</p>

<h3 id="部署私有docker镜像仓库">部署私有docker镜像仓库</h3>

<p><a href="https://github.com/goharbor/harbor/tags">harbor的github地址</a></p>

<p>下载软件，拷到 10.4.7.200 的 /opt/src目录下</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">/opt/src/harbor-offline-installer-v1.8.3.tgz</code></pre></div>
<p>解压软件到 /opt目录并做软链</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">tar xf /opt/src/harbor-offline-installer-v1.8.3.tgz -C /opt/
mv /opt/harbor /opt/harbor-v1.8.3
ln -s /opt/harbor-v1.8.3 /opt/harbor
效果
[root@hdss7-200 opt]# ls -l
总用量 0
drwxr-xr-x. 2 root root  71 4月  16 17:44 certs
drwx--x--x. 4 root root  28 4月  19 10:28 containerd
lrwxrwxrwx. 1 root root  19 4月  19 11:14 harbor -&gt; /opt/harbor-v1.8.3/</code></pre></div>
<p>修改harbor.yml</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">#修改hostname
hostname: harbor.od.com

#修改属性,将Port的80端口改为别的端口 180
http:
    port: 180

#修改harbor_admin_password 为更复杂的密码
harbor_admin_password: Harbor12345

# 数据位置
data_volume: /data/harbor
# 日志级别日志位置等
log:
  # options are debug, info, warning, error, fatal
  level: info
  # The directory on your host that store log
  location: /data/harbor/logs</code></pre></div>
<p>​<br />
安装 docker-compose,harbor依赖docker-compose做单机编排</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">yum install docker-compose -y</code></pre></div>
<p>执行harbor目录下的<code>install.sh</code></p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">sh /opt/harbor/install.sh

# 安装后，可以看到动了很多的docker程序
[root@hdss7-200 harbor]# docker-compose ps
  Name                     Command               State                 Ports
-----------------------------------------------------------------------------------------------
harbor-core         /harbor/start.sh                 Up
harbor-db           /entrypoint.sh postgres          Up      5432/tcp
harbor-jobservice   /harbor/start.sh                 Up
harbor-log          /bin/sh -c /usr/local/bin/ ...   Up      127.0.0.1:1514-&gt;10514/tcp
harbor-portal       nginx -g daemon off;             Up      80/tcp
nginx               nginx -g daemon off;             Up      0.0.0.0:180-&gt;80/tcp,:::180-&gt;80/tcp
redis               docker-entrypoint.sh redis ...   Up      6379/tcp
registry            /entrypoint.sh /etc/regist ...   Up      5000/tcp
registryctl         /harbor/start.sh                 Up</code></pre></div>
<blockquote>
<p>docker-compose命令的解释是 <code>Define and run multi-container applications with Docker.</code>，翻译为<code>使用Docker定义和运行多容器应用程序。</code></p>
</blockquote>

<p>安装 nginx 并配置</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">yum install nginx -y

# nginx配置
server {
    listen       80;
    server_name  harbor.od.com;

    client_max_body_size 1000m;

    location / {
        proxy_pass http://127.0.0.1:180;
    }
}

配置好后检查并启动

nginx -t
如果nginx没启动
systemctl start nginx

如果nginx启动了
nginx -s reload</code></pre></div>
<p>​<br />
启动好以后 ping harbor.od.com,发现无法访问，因为dns解析没有配置，这时我们到dns服务器 10.4.7.11上面调整dns服务</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">vi /var/named/od.com.zone

$ORIGIN od.com.
$TTL 600        ; 10 minutes
@       IN SOA  dns.od.com. dnsadmin.od.com. (
                                #首先serial的值要加1，否则可能不刷新 
                                2021041601 ; serial
                                100800     ; refresh (3 hours)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                86400      ; minimum (1 day)
                                )
                        NS    dns.od.com.

$TTL 60 ; 1 minute
dns                A    10.4.7.11
#然后增加解析
harbor             A    10.4.7.200</code></pre></div>
<p>​<br />
    # 配置修改好后重启 named
    systemctl restart named</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback"># 再检查 harbor.od.com 有解析了
[root@hdss7-11 named]# dig -t A harbor.od.com +short
10.4.7.200</code></pre></div>
<p>​<br />
再回到<code>10.4.7.200</code>上面，访问 <code>harbor.od.com</code>，由于是新装的系统，访问以后，报502，查看日志报错
参考文档[nginx访问502,日志报错:connect() to 127.0.0.1:180 failed (13: Permission denied)解决]（<a href="https://blog.csdn.net/wejack/article/details/115863740）">https://blog.csdn.net/wejack/article/details/115863740）</a> 解决</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">setsebool -P httpd_can_network_connect 1</code></pre></div>
<p>执行后在10.4.7.200上面执行，可以正常访问的到</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">[root@hdss7-200 nginx]# curl harbor.od.com</code></pre></div>
<p>然后通过浏览器访问 harbor.od.com，就能进入harbor的页面了，输入用户名 admin，密码 Harbor12345  （harbor.yml中配置的）就能入harbor了</p>

<div  align="center"><img src="https://wejack639.oss-cn-beijing.aliyuncs.com/blogimages/img/1618814544472-20210419144222.png" width = 800 /> </div>

<p>新建一个public仓库</p>

<div  align="center"><img src="https://wejack639.oss-cn-beijing.aliyuncs.com/blogimages/img/1618814626918-20210419144344.png" width = 400 /> </div>

<p>然后我们就可以向仓库中推镜像了</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">[root@hdss7-200 nginx]# docker pull nginx:1.7.9
[root@hdss7-200 nginx]# docker tag 84581e99d807 harbor.od.com/public/nginx:v1.7.9
[root@hdss7-200 nginx]# docker login harbor.od.com
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
[root@hdss7-200 nginx]# docker push harbor.od.com/public/nginx:v1.7.9</code></pre></div>
<p>然后我们在镜像仓库中就可以看到我们打的标签了</p>

<div  align="center"><img src="https://wejack639.oss-cn-beijing.aliyuncs.com/blogimages/img/1618815130430-20210419145208.png" width = 800 /> </div>

<h2 id="部署k8s的master节点">部署k8s的master节点</h2>

<h3 id="部署etcd集群">部署etcd集群</h3>

<p>集群规划
| 主机名            | 角色        | ip             |
| &mdash;&mdash;&mdash;&mdash;&mdash;&ndash; | &mdash;&mdash;&mdash;&ndash; | &mdash;&mdash;&mdash;&mdash;&ndash; |
| HDss7-12.host.com | ectc lead   | 192.168.154.12 |
| HDss7-21.host.com | ectc follow | 192.168.154.21 |
| HDss7-22.host.com | ectc follow | 192.168.154.22 |</p>

<p>进入10.4.7.200服务器，生成证书</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-fallback" data-lang="fallback">vi /opt/certs/ca-config.json
#这配置提供了创建 ca使用的profile,
# client指的是客户端找服务器端需要证书，服务器端找客户端不需要
# server指的是服务端启动以及
# peer端是两边都需要
{
    &#34;signing&#34;: {
        &#34;default&#34;: {
            &#34;expiry&#34;: &#34;175200h&#34;
        },
        &#34;profiles&#34;: {
            &#34;server&#34;: {
                &#34;expiry&#34;: &#34;175200h&#34;,
                &#34;usages&#34;: [
                    &#34;signing&#34;,
                    &#34;key encipherment&#34;,
                    &#34;server auth&#34;
                ]
            },
            &#34;client&#34;: {
                &#34;expiry&#34;: &#34;175200h&#34;,
                &#34;usages&#34;: [
                    &#34;signing&#34;,
                    &#34;key encipherment&#34;,
                    &#34;client auth&#34;
                ]
            },
            &#34;peer&#34;: {
                &#34;expiry&#34;: &#34;175200h&#34;,
                &#34;usages&#34;: [
                    &#34;signing&#34;,
                    &#34;key encipherment&#34;,
                    &#34;server auth&#34;,
                    &#34;client auth&#34;
                ]
            }
        }
    }
}</code></pre></div>
<p>​</p>

    </div>
    <footer class="post-footer">
     

     <div class="post-nav">
    <div class="post-nav-next post-nav-item">
    
        <a href="http://www.shutdown.cn/post/jvm%E5%AD%A6%E4%B9%A005-%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6%E5%99%A8%E5%92%8C%E5%86%85%E5%AD%98%E5%88%86%E9%85%8D/" rel="next" title="">
        <i class="fa fa-chevron-left"></i> 
        </a>
    
    </div>

    <div class="post-nav-prev post-nav-item">
    
        <a href="http://www.shutdown.cn/post/kafka%E6%97%A5%E5%BF%97%E9%87%87%E9%9B%86%E9%85%8D%E7%BD%AE%E8%AE%B0%E5%BD%95/" rel="prev" title="">
         <i class="fa fa-chevron-right"></i>
        </a>
    
    </div>
</div>
      
     
     
     






    </footer>
  </article>
</section>

          </div>
        </div>
        <div class="sidebar-toggle">
  <div class="sidebar-toggle-line-wrap">
    <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
    <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
    <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
  </div>
</div>
<aside id="sidebar" class="sidebar">
  <div class="sidebar-inner">

    <section class="site-overview sidebar-panel  sidebar-panel-active ">
      <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
        src="http://www.shutdown.cn/img/author.jpg"
        alt="不与天斗Domino" />
    <p class="site-author-name" itemprop="name">不与天斗Domino</p>
    <p class="site-description motion-element" itemprop="description"> 
        Programmer &amp; Architect</p>
</div>
      <nav class="site-state motion-element">
    <div class="site-state-item site-state-posts">
      <a href="http://www.shutdown.cn/post/">
        <span class="site-state-item-count">172</span>
        <span class="site-state-item-name">日志</span>
      </a>
    </div>
    <div class="site-state-item site-state-categories">    
        <a href="http://www.shutdown.cn/categories/">      
         
        <span class="site-state-item-count">10</span>
        
        <span class="site-state-item-name">分类</span>
        
        </a>
    </div>

    <div class="site-state-item site-state-tags">
        <a href="http://www.shutdown.cn/tags/">
         
        <span class="site-state-item-count">96</span>
        
        <span class="site-state-item-name">标签</span>
        </a>
    </div>
</nav>
      
      

      

      <div class="links-of-blogroll motion-element inline">
<script type="text/javascript" src="//rf.revolvermaps.com/0/0/8.js?i=&amp;m=0&amp;s=220&amp;c=ff0000&amp;cr1=ffffff&amp;f=arial&amp;l=33&amp;bv=35" async="async"></script>
</div>

    </section>
    
  </div>
</aside>

      </div>
    </main>
   
    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  <span itemprop="copyrightYear">  &copy; 
  2013 - 2022</span>
  <span class="with-love"><i class="fa fa-heart"></i></span>
  <span class="author" itemprop="copyrightHolder">天地维杰网</span>
  <span class="icp" itemprop="copyrightHolder"><a href="https://beian.miit.gov.cn/" target="_blank">京ICP备13019191号-1</a></span>
</div>
<div class="powered-by">
  Powered by - <a class="theme-link" href="http://gohugo.io" target="_blank" title="hugo" >Hugo v0.63.2</a>
</div>
<div class="theme-info">
  Theme by - <a class="theme-link" href="https://github.com/xtfly/hugo-theme-next" target="_blank"> NexT
  </a>
</div>


      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
      <span id="scrollpercent"><span>0</span>%</span>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/jquery/index.js?v=2.1.3"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/fastclick/lib/fastclick.min.js?v=1.0.6"></script> 
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/velocity/velocity.min.js?v=1.2.1"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script src="http://www.shutdown.cn/js/vendor/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>

<script src="http://www.shutdown.cn/js/vendor/fancybox/jquery.fancybox.pack.js?v=2.1.5"></script>

<script type="text/javascript" src="http://www.shutdown.cn/js/utils.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/motion.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/affix.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/schemes/pisces.js"></script>

<script type="text/javascript" src="http://www.shutdown.cn/js/scrollspy.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/post-details.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/toc.js"></script>

<script type="text/javascript" src="http://www.shutdown.cn/js/bootstrap.js"></script>

<script type="text/javascript" src="http://www.shutdown.cn/js/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
      inlineMath: [ ['$','$'] ],
      displayMath: [ ['$$','$$'] ],
      processEscapes: true
    },
    "HTML-CSS": { fonts: ["TeX"] }
  });
</script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML' async></script>
</body>
</html>